package com.sm.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class AttendanceUtil {
     private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    static public String getDateStr(){
        return simpleDateFormat.format(new Date());
    }

    static public String getYseterdayStr(){
        Date today = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
        return simpleDateFormat.format(today);
    }

    static public String getStrByDate(Date date){
        return simpleDateFormat.format(date);
    }

    static public Integer getMonth(){
        Calendar calendar = new GregorianCalendar();
        Integer mm = calendar.get(Calendar.MONTH);
        return (mm+1)%3;
    }

    static public Integer getLastMonth(){
        Calendar calendar = new GregorianCalendar();
        Integer mm = calendar.get(Calendar.MONTH);
        if(mm==0)
            mm+=12;
        return (mm)%3;
    }

    static public Integer getDelMonth(){
        Calendar calendar = new GregorianCalendar();
        Integer mm = calendar.get(Calendar.MONTH);
        if(mm<=1)
            mm+=12;
        return (mm-1)%3;
    }
}
